home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 551-575 / disk_570 / gadtoolsbox / source / source.lha / ItemEd.c < prev    next >
C/C++ Source or Header  |  1991-11-04  |  24KB  |  614 lines

  1. /*-- AutoRev header do NOT edit!
  2. *
  3. *   Program         :   ItemEd.c
  4. *   Copyright       :   © Copyright 1991 Jaba Development
  5. *   Author          :   Jan van den Baard
  6. *   Creation Date   :   30-Oct-91
  7. *   Current version :   1.00
  8. *   Translator      :   DICE v2.6
  9. *
  10. *   REVISION HISTORY
  11. *
  12. *   Date          Version         Comment
  13. *   ---------     -------         ------------------------------------------
  14. *   30-Oct-91     1.00            (Sub)Item edit requester.
  15. *
  16. *-- REV_END --*/
  17.  
  18. #include "GTEd.h"
  19. #include "Protos.h"
  20.  
  21. /*
  22.  * --- External referenced data.
  23.  */
  24. extern ULONG                 Class;
  25. extern UWORD                 Code;
  26. extern struct TextAttr       Topaz80, MainFont;
  27. extern APTR                  MainVisualInfo;
  28. extern struct Screen        *MainScreen;
  29. extern struct Window        *MainWindow, *meWnd;
  30. extern struct Gadget        *Object;
  31. extern struct MemoryChain   *Chain;
  32. extern struct Menu          *MainMenus;
  33. extern UBYTE                 MainScreenTitle[80], MainWindowTitle[80];
  34. extern BOOL                  Saved;
  35.  
  36. /*
  37.  * --- Gadget ID
  38.  */
  39. #define GD_LIST          0
  40. #define GD_ENTER         1
  41. #define GD_DISABLED      2
  42. #define GD_CHECKIT       3
  43. #define GD_TOGGLE        4
  44. #define GD_CHECKED       5
  45. #define GD_SHORTCUT      6
  46. #define GD_ITEMED        7
  47. #define GD_BARLABEL      8
  48. #define GD_DELETE        9
  49. #define GD_DONE          10
  50.  
  51. /*
  52.  * --- Module data.
  53.  */
  54. struct Window           *ieWnd   = NULL;
  55. struct Gadget           *ieGList = NULL;
  56. struct Gadget           *ieGadgets[8];
  57. struct ExtNewMenu       *ieItem = 0l;
  58. UWORD                    ieActEd = NM_ITEM;
  59. struct ExtMenuList      *ieList, *ieParent;
  60.  
  61. BOOL                     ieDisabled = FALSE, ieCheckit = FALSE;
  62. BOOL                     ieToggle = FALSE, ieChecked = FALSE;
  63.  
  64. WORD                     ieZoom[4];
  65.  
  66. struct TagItem           ienwTags[] = {
  67.     WA_Left,                0l,
  68.     WA_Top,                 0l,
  69.     WA_Width,               0l,
  70.     WA_Height,              0l,
  71.     WA_IDCMP,               IDCMP_CLOSEWINDOW | BUTTONIDCMP | LISTVIEWIDCMP  | CHECKBOXIDCMP | IDCMP_VANILLAKEY | IDCMP_REFRESHWINDOW,
  72.     WA_Flags,               WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET | WFLG_ACTIVATE | WFLG_SMART_REFRESH,
  73.     WA_Gadgets,             0l,
  74.     WA_Title,               "Edit Items",
  75.     WA_AutoAdjust,          TRUE,
  76.     WA_Zoom,                (Tag)ieZoom,
  77.     WA_CustomScreen,        0l,
  78.     TAG_DONE };
  79.  
  80. /*
  81.  * --- Set the MutualExclude for a item or a subitem
  82.  */
  83. void MutualExclude( void )
  84. {
  85.     struct ExtNewMenu   *item;
  86.     struct NewMenu      *strip, *tmp;
  87.     struct Menu         *themenu;
  88.     struct MenuItem     *excluding;
  89.     LONG                 mutex = 0l, bitnum = 0l, numitems = 0l;
  90.  
  91.     GT_SetGadgetAttrs( ieGadgets[ GD_LIST], ieWnd, 0l, GTLV_Labels, ~0, TAG_DONE );
  92.  
  93.     for ( item = ieList->ml_First; item->em_Next; item = item->em_Next, numitems++ );
  94.  
  95.     if ( numitems <= 1 ) goto noWay;
  96.  
  97.     numitems += 2;
  98.  
  99.     if ( strip = tmp = ( struct NewMenu * )AllocItem( Chain, (long)sizeof( struct NewMenu ) * numitems, MEMF_PUBLIC )) {
  100.         tmp->nm_Type  = NM_TITLE;
  101.         tmp->nm_Label = "MutualExclusion";
  102.         tmp++;
  103.         for ( item = ieList->ml_First; item->em_Next; item = item->em_Next ) {
  104.             tmp->nm_Type  = NM_ITEM;
  105.             tmp->nm_Label = item->em_NodeName;
  106.             tmp->nm_Flags = CHECKIT | MENUTOGGLE;
  107.  
  108.             if (( ieItem->em_NewMenu.nm_MutualExclude & ( 1 << bitnum )) == ( 1 << bitnum ))
  109.                 tmp->nm_Flags |= CHECKED;
  110.  
  111.             if ( item == ieItem )
  112.                 tmp->nm_Flags |= NM_ITEMDISABLED;
  113.  
  114.             tmp++;
  115.             bitnum++;
  116.         }
  117.  
  118.         tmp->nm_Type = NM_END;
  119.  
  120.         if ( themenu = CreateMenus( strip, GTMN_FrontPen, 0l, TAG_DONE )) {
  121.             LayoutMenus( themenu, MainVisualInfo, GTMN_TextAttr, &MainFont, TAG_DONE );
  122.  
  123.             Forbid();
  124.             ieWnd->Flags &= ~WFLG_RMBTRAP;
  125.             Permit();
  126.  
  127.             ModifyIDCMP( ieWnd, IDCMP_MENUPICK | IDCMP_RAWKEY | IDCMP_REFRESHWINDOW );
  128.  
  129.             SetMenuStrip( ieWnd, themenu );
  130.             SetWindowTitles( ieWnd, "DRAG-SELECT ITEMS TO EXCLUDE", ( char * ) ~0 );
  131.  
  132.             while ( 1 ) {
  133.                 WaitPort( ieWnd->UserPort );
  134.                 while( ReadIMsg( ieWnd )) {
  135.                     switch ( Class ) {
  136.  
  137.                         case    IDCMP_RAWKEY:
  138.                             if ( Code == 0x45 )
  139.                                 goto Esc;
  140.                             break;
  141.  
  142.                         case    IDCMP_MENUPICK:
  143.                             if ( Code != MENUNULL )
  144.                                 goto doIt;
  145.                             break;
  146.  
  147.                         case IDCMP_REFRESHWINDOW:
  148.                             GT_BeginRefresh( ieWnd );
  149.                             GT_EndRefresh( ieWnd, TRUE );
  150.                             break;
  151.                         }
  152.                 }
  153.             }
  154.  
  155.             doIt:
  156.             excluding = ItemAddress( themenu, SHIFTMENU( 0 ) | SHIFTITEM( 0 ) | SHIFTSUB( NOSUB ));
  157.  
  158.             bitnum = 0l;
  159.             ieItem->em_NewMenu.nm_MutualExclude = 0l;
  160.  
  161.             while ( excluding ) {
  162.                 if (( excluding->Flags & CHECKED ) == CHECKED )
  163.                     ieItem->em_NewMenu.nm_MutualExclude |= ( 1 << bitnum );
  164.                 bitnum++;
  165.                 excluding = excluding->NextItem;
  166.             }
  167.  
  168.             Esc:
  169.             ClearMenuStrip( ieWnd );
  170.             Forbid();
  171.             ieWnd->Flags |= WFLG_RMBTRAP;
  172.             Permit();
  173.             ModifyIDCMP( ieWnd, ienwTags[4].ti_Data );
  174.             if ( ieActEd == NM_ITEM ) SetWindowTitles( ieWnd, "Edit Items:", ( char * )~0 );
  175.             else                      SetWindowTitles( ieWnd, "Edit SubItems:", ( char * )~0 );
  176.             FreeMenus( themenu );
  177.         }
  178.         FreeItem( Chain, strip, (long)sizeof( struct NewMenu ) * numitems );
  179.     }
  180.  
  181.     noWay:
  182.     GT_SetGadgetAttrs( ieGadgets[ GD_LIST ], ieWnd, 0l, GTLV_Labels, ieList, TAG_DONE );
  183. }
  184.  
  185.  
  186. /*
  187.  * --- Set ed for items or subs
  188.  */
  189. void SetEd( long type, struct ExtNewMenu *item )
  190. {
  191.     GT_SetGadgetAttrs( ieGadgets[ GD_LIST ], ieWnd, 0l, GTLV_Labels, ~0, TAG_DONE );
  192.  
  193.     if ( type == NM_SUB ) {
  194.         if ( NOT( ieList = item->em_Items )) {
  195.             if ( NOT( item->em_Items = AllocItem( Chain, (long)sizeof( struct ExtMenuList ), MEMF_PUBLIC )))
  196.                 return;
  197.  
  198.             ieList = item->em_Items;
  199.             NewList(( struct List * )ieList );
  200.         }
  201.         SetWindowTitles( ieWnd, "Edit SubItems:", (char *)-1l );
  202.         GT_SetGadgetAttrs( ieGadgets[ GD_ITEMED ], ieWnd, 0l, GA_Disabled, TRUE, TAG_DONE );
  203.         ieActEd  = NM_SUB;
  204.     } else {
  205.         SetWindowTitles( ieWnd, "Edit Items:", (char *)-1l );
  206.         GT_SetGadgetAttrs( ieGadgets[ GD_ITEMED ], ieWnd, 0l, GA_Disabled, FALSE, TAG_DONE );
  207.         ieList  = ieParent;
  208.         ieActEd = NM_ITEM;
  209.     }
  210.  
  211.     GT_SetGadgetAttrs( ieGadgets[ GD_DISABLED ], ieWnd, 0l, GTCB_Checked, FALSE, TAG_DONE );
  212.     GT_SetGadgetAttrs( ieGadgets[ GD_CHECKIT  ], ieWnd, 0l, GTCB_Checked, FALSE, TAG_DONE );
  213.     GT_SetGadgetAttrs( ieGadgets[ GD_CHECKED  ], ieWnd, 0l, GTCB_Checked, FALSE, TAG_DONE );
  214.     GT_SetGadgetAttrs( ieGadgets[ GD_TOGGLE   ], ieWnd, 0l, GTCB_Checked, FALSE, TAG_DONE );
  215.     GT_SetGadgetAttrs( ieGadgets[ GD_SHORTCUT ], ieWnd, 0l, GTST_String, 0l, TAG_DONE );
  216.  
  217.     ieDisabled = ieCheckit = ieChecked = ieToggle = FALSE;
  218.  
  219.     GT_SetGadgetAttrs( ieGadgets[ GD_LIST ], ieWnd, 0l, GTLV_Labels, ieList, TAG_DONE );
  220.  
  221.     ieItem = 0l;
  222. }
  223.  
  224. /*
  225.  * --- Set the used flags
  226.  */
  227. void SetTheFlags( struct ExtNewMenu *item )
  228. {
  229.     UBYTE           *ptr;
  230.  
  231.     ptr = (( struct StringInfo * )ieGadgets[ GD_SHORTCUT ]->SpecialInfo )->Buffer;
  232.  
  233.     if ( ieDisabled ) item->em_NewMenu.nm_Flags |= NM_ITEMDISABLED;
  234.     else              item->em_NewMenu.nm_Flags &= ~NM_ITEMDISABLED;
  235.     if ( ieCheckit  ) item->em_NewMenu.nm_Flags |= CHECKIT;
  236.     else              item->em_NewMenu.nm_Flags &= ~CHECKIT;
  237.     if ( ieChecked  ) item->em_NewMenu.nm_Flags |= CHECKED;
  238.     else              item->em_NewMenu.nm_Flags &= ~CHECKED;
  239.     if ( ieToggle   ) item->em_NewMenu.nm_Flags |= MENUTOGGLE;
  240.     else              item->em_NewMenu.nm_Flags &= ~MENUTOGGLE;
  241.  
  242.     if ( strlen( ptr )) {
  243.         strcpy( &item->em_ShortCut[0], ptr );
  244.         item->em_NewMenu.nm_CommKey = &item->em_ShortCut[0];
  245.     } else
  246.         item->em_NewMenu.nm_CommKey = 0l;
  247. }
  248.  
  249. /*
  250.  * --- Display the Item Edit requester.
  251.  */
  252. long ItemEdit( struct ExtNewMenu *parent )
  253. {
  254.     struct Gadget       *g;
  255.     struct NewGadget     ng;
  256.     BOOL                 running =  TRUE;
  257.     WORD                 l, t, w, h, btop, bleft;
  258.     struct ExtNewMenu   *menu, *dummy;
  259.     UBYTE               *ptr;
  260.  
  261.     btop  = MainScreen->WBorTop + MainScreen->RastPort.TxHeight;
  262.     bleft = MainScreen->WBorLeft;
  263.  
  264.     w = bleft + MainScreen->WBorRight  + 300;
  265.     h = btop  + MainScreen->WBorBottom + 147;
  266.     l = (( MainScreen->Width  >> 1 ) - ( w >> 1 ));
  267.     t = (( MainScreen->Height >> 1 ) - ( h >> 1 ));
  268.  
  269.     ieZoom[0] = 0;
  270.     ieZoom[1] = btop;
  271.     ieZoom[2] = 200;
  272.     ieZoom[3] = btop;
  273.  
  274.     ienwTags[0].ti_Data = l;
  275.     ienwTags[1].ti_Data = t;
  276.     ienwTags[2].ti_Data = w;
  277.     ienwTags[3].ti_Data = h;
  278.  
  279.     ienwTags[10].ti_Data = (Tag)MainScreen;
  280.  
  281.     if (( MainScreen->Flags & CUSTOMSCREEN) == CUSTOMSCREEN )
  282.         ienwTags[10].ti_Tag  = WA_CustomScreen;
  283.     else if (( MainScreen->Flags & PUBLICSCREEN ) == PUBLICSCREEN )
  284.         ienwTags[10].ti_Tag  = WA_PubScreen;
  285.     else
  286.         ienwTags[10].ti_Tag  = TAG_DONE;
  287.  
  288.     ieDisabled = ieCheckit = ieToggle = ieChecked = FALSE;
  289.  
  290.     ieList = parent->em_Items;
  291.  
  292.     if ( parent->em_NewMenu.nm_Type == NM_TITLE ) {
  293.         if ( ieList->ml_First->em_Dummy )
  294.             FreeMenuList( ieList, FALSE );
  295.     }
  296.  
  297.     if ( g = CreateContext( &ieGList )) {
  298.  
  299.         ng.ng_Width         =   284;
  300.         ng.ng_Height        =   12;
  301.         ng.ng_GadgetText    =   0l;
  302.         ng.ng_GadgetID      =   GD_ENTER;
  303.         ng.ng_TextAttr      =   &Topaz80;
  304.         ng.ng_VisualInfo    =   MainVisualInfo;
  305.  
  306.         g = CreateGadget( STRING_KIND, g, &ng, GTST_MaxChars, GT_MAXLABELNAME + 1, GT_Underscore, '_', TAG_DONE );
  307.  
  308.         SetStringGadget( g );
  309.  
  310.         ieGadgets[ GD_ENTER ] = g;
  311.  
  312.         ng.ng_LeftEdge      =   bleft + 8;
  313.         ng.ng_TopEdge       =   btop + 16;
  314.         ng.ng_Width         =   284;
  315.         ng.ng_Height        =   60;
  316.         ng.ng_GadgetText    =   "(Sub)Items:";
  317.         ng.ng_GadgetID      =   GD_LIST;
  318.         ng.ng_Flags         =   PLACETEXT_ABOVE;
  319.  
  320.         g = CreateGadget( LISTVIEW_KIND, g, &ng, GTLV_Labels, ieList, GTLV_ShowSelected, ieGadgets[ GD_ENTER ], GTLV_Selected, ~0, TAG_DONE );
  321.  
  322.         ieGadgets[ GD_LIST ] = g;
  323.  
  324.         ng.ng_LeftEdge      =   bleft + 266;
  325.         ng.ng_TopEdge       =   btop + 85;
  326.         ng.ng_GadgetText    =   "_Disabled";
  327.         ng.ng_Flags         =   PLACETEXT_LEFT;
  328.         ng.ng_GadgetID      =   GD_DISABLED;
  329.  
  330.         g = CreateGadget( CHECKBOX_KIND, g, &ng, GT_Underscore, '_', TAG_DONE );
  331.  
  332.         ieGadgets[ GD_DISABLED ] = g;
  333.  
  334.         ng.ng_LeftEdge      =   bleft + 125;
  335.         ng.ng_GadgetText    =   "Check_it";
  336.         ng.ng_GadgetID      =   GD_CHECKIT;
  337.  
  338.         g = CreateGadget( CHECKBOX_KIND, g, &ng, GT_Underscore, '_', TAG_DONE );
  339.  
  340.         ieGadgets[ GD_CHECKIT ] = g;
  341.  
  342.         ng.ng_TopEdge       =   btop + 100;
  343.         ng.ng_GadgetText    =   "_Checked";
  344.         ng.ng_GadgetID      =   GD_CHECKED;
  345.  
  346.         g = CreateGadget( CHECKBOX_KIND, g, &ng, GT_Underscore, '_', TAG_DONE );
  347.  
  348.         ieGadgets[ GD_CHECKED ] = g;
  349.  
  350.         ng.ng_LeftEdge      =   bleft + 266;
  351.         ng.ng_GadgetText    =   "_MenuToggle";
  352.         ng.ng_GadgetID      =   GD_TOGGLE;
  353.  
  354.         g = CreateGadget( CHECKBOX_KIND, g, &ng, GT_Underscore, '_', TAG_DONE );
  355.  
  356.         ieGadgets[ GD_TOGGLE ] = g;
  357.  
  358.         ng.ng_LeftEdge      =   bleft + 125;
  359.         ng.ng_TopEdge       =   btop + 114;
  360.         ng.ng_Width         =   167;
  361.         ng.ng_Height        =   12;
  362.         ng.ng_GadgetText    =   "_ShortCut";
  363.         ng.ng_GadgetID      =   GD_SHORTCUT;
  364.  
  365.         g = CreateGadget( STRING_KIND, g, &ng, GTST_MaxChars, 1l, GT_Underscore, '_', TAG_DONE );
  366.  
  367.         SetStringGadget( g );
  368.  
  369.         ieGadgets[ GD_SHORTCUT ] = g;
  370.  
  371.         ng.ng_TopEdge       =   btop + 130;
  372.         ng.ng_LeftEdge      =   bleft + 231;
  373.         ng.ng_Width         =   60;
  374.         ng.ng_Height        =   13;
  375.         ng.ng_GadgetText    =   "D_ONE";
  376.         ng.ng_GadgetID      =   GD_DONE;
  377.         ng.ng_Flags         =   PLACETEXT_IN;
  378.  
  379.         g = CreateGadget( BUTTON_KIND, g, &ng, GT_Underscore, '_', TAG_DONE );
  380.  
  381.         ng.ng_LeftEdge      =   bleft + 83;
  382.         ng.ng_GadgetText    =   "S_ubEd";
  383.         ng.ng_GadgetID      =   GD_ITEMED;
  384.  
  385.         g = CreateGadget( BUTTON_KIND, g, &ng, GT_Underscore, '_', TAG_DONE );
  386.  
  387.         ieGadgets[ GD_ITEMED ] = g;
  388.  
  389.         ng.ng_LeftEdge      =   bleft + 158;
  390.         ng.ng_GadgetText    =   "D_elete";
  391.         ng.ng_GadgetID      =   GD_DELETE;
  392.  
  393.         g = CreateGadget( BUTTON_KIND, g, &ng, GT_Underscore, '_', TAG_DONE );
  394.  
  395.         ng.ng_LeftEdge      =   bleft + 8;
  396.         ng.ng_GadgetText    =   "_BarLab";
  397.         ng.ng_GadgetID      =   GD_BARLABEL;
  398.  
  399.         g = CreateGadget( BUTTON_KIND, g, &ng, GT_Underscore, '_', TAG_DONE );
  400.  
  401.         if ( g ) {
  402.  
  403.             ienwTags[6].ti_Data = (Tag)ieGList;
  404.  
  405.             if ( ieWnd = OpenWindowTagList( NULL, ienwTags )) {
  406.  
  407.                 ieZoom[0] = l;
  408.                 ieZoom[1] = t;
  409.                 ieZoom[2] = w;
  410.                 ieZoom[3] = h;
  411.  
  412.                 GT_RefreshWindow( ieWnd, NULL );
  413.  
  414.                 do {
  415.                     WaitPort( ieWnd->UserPort );
  416.  
  417.                     while ( ReadIMsg( ieWnd )) {
  418.  
  419.                         switch ( Class ) {
  420.  
  421.                             case    IDCMP_REFRESHWINDOW:
  422.                                 GT_BeginRefresh( ieWnd );
  423.                                 GT_EndRefresh( ieWnd, TRUE );
  424.                                 break;
  425.  
  426.                             case    IDCMP_CLOSEWINDOW:
  427.                                 running = FALSE;
  428.                                 break;
  429.  
  430.                             case    IDCMP_VANILLAKEY:
  431.                                 switch( Code ) {
  432.  
  433.                                     case    'd':
  434.                                         FlipFlop( ieWnd, ieGadgets, GD_DISABLED, &ieDisabled );
  435.                                         break;
  436.  
  437.                                     case    'i':
  438.                                         FlipFlop( ieWnd, ieGadgets, GD_CHECKIT, &ieCheckit );
  439.                                         break;
  440.  
  441.                                     case    'c':
  442.                                         FlipFlop( ieWnd, ieGadgets, GD_CHECKED, &ieChecked );
  443.                                         break;
  444.  
  445.                                     case    'm':
  446.                                         FlipFlop( ieWnd, ieGadgets, GD_TOGGLE, &ieToggle );
  447.                                         break;
  448.  
  449.                                     case    's':
  450.                                         ActivateGadget( ieGadgets[ GD_SHORTCUT ], ieWnd, 0l );
  451.                                         break;
  452.  
  453.                                     case    'u':
  454.                                         if ( ieActEd == NM_ITEM )
  455.                                             goto Sub;
  456.                                         break;
  457.  
  458.                                     case    'e':
  459.                                         goto Delete;
  460.  
  461.                                     case    'o':
  462.                                         goto Done;
  463.  
  464.                                     case    'x':
  465.                                         if ( ieItem ) {
  466.                                             MutualExclude();
  467.                                             ieItem = 0l;
  468.                                         }
  469.                                         break;
  470.                                 }
  471.                                 break;
  472.  
  473.                             case    IDCMP_GADGETUP:
  474.                                 switch ( Object->GadgetID ) {
  475.  
  476.                                     case    GD_LIST:
  477.                                         if ( ieItem ) SetTheFlags( ieItem );
  478.                                         ieItem = ( struct ExtNewMenu * )FindNode(( struct List * )ieList, Code );
  479.                                         if (( ieItem->em_NewMenu.nm_Flags & NM_ITEMDISABLED ) == NM_ITEMDISABLED )
  480.                                             ieDisabled = TRUE; else ieDisabled = FALSE;
  481.                                         if (( ieItem->em_NewMenu.nm_Flags & CHECKIT ) == CHECKIT )
  482.                                             ieCheckit = TRUE; else ieCheckit = FALSE;
  483.                                         if (( ieItem->em_NewMenu.nm_Flags & CHECKED ) == CHECKED )
  484.                                             ieChecked = TRUE; else ieChecked = FALSE;
  485.                                         if (( ieItem->em_NewMenu.nm_Flags & MENUTOGGLE ) == MENUTOGGLE )
  486.                                             ieToggle = TRUE; else ieToggle = FALSE;
  487.  
  488.                                         GT_SetGadgetAttrs( ieGadgets[ GD_DISABLED ], ieWnd, 0l, GTCB_Checked, ieDisabled, TAG_DONE );
  489.                                         GT_SetGadgetAttrs( ieGadgets[ GD_CHECKIT  ], ieWnd, 0l, GTCB_Checked, ieCheckit, TAG_DONE );
  490.                                         GT_SetGadgetAttrs( ieGadgets[ GD_CHECKED  ], ieWnd, 0l, GTCB_Checked, ieChecked, TAG_DONE );
  491.                                         GT_SetGadgetAttrs( ieGadgets[ GD_TOGGLE ], ieWnd, 0l, GTCB_Checked, ieToggle, TAG_DONE );
  492.                                         if ( ieItem->em_NewMenu.nm_CommKey )
  493.                                             GT_SetGadgetAttrs( ieGadgets[ GD_SHORTCUT ], ieWnd, 0l, GTST_String, ieItem->em_NewMenu.nm_CommKey, TAG_DONE );
  494.                                         else
  495.                                             GT_SetGadgetAttrs( ieGadgets[ GD_SHORTCUT ], ieWnd, 0l, GTST_String, 0l, TAG_DONE );
  496.                                         break;
  497.  
  498.                                     case    GD_ENTER:
  499.                                         ptr = (( struct StringInfo * )ieGadgets[ GD_ENTER ]->SpecialInfo )->Buffer;
  500.  
  501.                                         if ( strlen( ptr )) {
  502.                                             if ( NOT ieItem ) {
  503.                                                 if ( menu = GetExtMenu( ptr, ieActEd )) {
  504.                                                     GT_SetGadgetAttrs( ieGadgets[ GD_LIST ], ieWnd, 0l, GTLV_Labels, ~0, TAG_DONE );
  505.                                                     SetTheFlags( menu );
  506.                                                     AddTail(( struct List * )ieList, ( struct Node * )menu );
  507.                                                     GT_SetGadgetAttrs( ieGadgets[ GD_LIST ], ieWnd, 0l, GTLV_Labels, ieList, TAG_DONE );
  508.                                                     ieItem = 0l;
  509.                                                 }
  510.                                             } else {
  511.                                                 if ( ieItem->em_NewMenu.nm_Label != NM_BARLABEL ) {
  512.                                                     GT_SetGadgetAttrs( ieGadgets[ GD_LIST ], ieWnd, 0l, GTLV_Labels, ~0, TAG_DONE );
  513.                                                     strcpy( &ieItem->em_TheMenuName[0], ptr );
  514.                                                     SetTheFlags( ieItem );
  515.                                                     GT_SetGadgetAttrs( ieGadgets[ GD_LIST ], ieWnd, 0l, GTLV_Labels, ieList, TAG_DONE );
  516.                                                     ieItem = 0l;
  517.                                                 } else {
  518.                                                     GT_SetGadgetAttrs( ieGadgets[ GD_ENTER ], ieWnd, 0l, GTST_String, "NM_BARLABEL", TAG_DONE );
  519.                                                     DisplayBeep( MainScreen );
  520.                                                 }
  521.                                             }
  522.                                             GT_SetGadgetAttrs( ieGadgets[ GD_SHORTCUT ], ieWnd, 0l, GTST_String, 0l, TAG_DONE );
  523.                                         }
  524.                                         break;
  525.  
  526.                                     case    GD_DISABLED:
  527.                                         FlipFlop( 0l, 0l, 0l, &ieDisabled );
  528.                                         break;
  529.  
  530.                                     case    GD_CHECKIT:
  531.                                         FlipFlop( 0l, 0l, 0l, &ieCheckit );
  532.                                         break;
  533.  
  534.                                     case    GD_CHECKED:
  535.                                         FlipFlop( 0l, 0l, 0l, &ieChecked );
  536.                                         break;
  537.  
  538.                                     case    GD_TOGGLE:
  539.                                         FlipFlop( 0l, 0l, 0l, &ieToggle );
  540.                                         break;
  541.  
  542.                                     case    GD_DELETE:
  543.                                         Delete:
  544.                                         if ( ieItem ) {
  545.                                             if ( MyRequest( "Excuse me..", "YES|NO", "--> %s <--\nAre you sure you want\nto delete this item?" , ieItem->em_NodeName )) {
  546.                                                 GT_SetGadgetAttrs( ieGadgets[ GD_LIST ], ieWnd, 0l, GTLV_Labels, ~0, TAG_DONE );
  547.                                                 Remove(( struct Node * )ieItem );
  548.                                                 FreeMenu( ieItem );
  549.                                                 GT_SetGadgetAttrs( ieGadgets[ GD_LIST ], ieWnd, 0l, GTLV_Labels, ieList, TAG_DONE );
  550.                                                 ieItem = 0l;
  551.                                             }
  552.                                         }
  553.                                         break;
  554.  
  555.                                     case    GD_DONE:
  556.                                         Done:
  557.                                         if ( ieActEd == NM_SUB ) {
  558.                                             SetTheFlags( ieItem );
  559.                                             SetEd( NM_ITEM, 0l );
  560.                                             break;
  561.                                         }
  562.                                         running = FALSE;
  563.                                         break;
  564.  
  565.                                     case    GD_ITEMED:
  566.                                         Sub:
  567.                                         if ( ieItem ) {
  568.                                             ieParent = ieList;
  569.                                             SetEd( NM_SUB, ieItem );
  570.                                         }
  571.                                         break;
  572.  
  573.                                     case    GD_BARLABEL:
  574.                                         Label:
  575.                                         if ( menu = GetExtMenu( "", ieActEd )) {
  576.                                             strcpy( &menu->em_TheMenuName[0], "NM_BARLABEL" );
  577.                                             menu->em_NewMenu.nm_Label = NM_BARLABEL;
  578.                                             GT_SetGadgetAttrs( ieGadgets[ GD_LIST ], ieWnd, 0l, GTLV_Labels, ~0, TAG_DONE );
  579.                                             AddTail(( struct List * )ieList, ( struct Node * )menu );
  580.                                             GT_SetGadgetAttrs( ieGadgets[ GD_LIST ], ieWnd, 0l, GTLV_Labels, ieList, TAG_DONE );
  581.                                             ieItem = 0l;
  582.                                         }
  583.                                 }
  584.                                 break;
  585.                         }
  586.                     }
  587.                 } while ( running );
  588.             }
  589.         }
  590.     }
  591.  
  592.     if ( ieItem )
  593.         SetTheFlags( ieItem );
  594.  
  595.     if ( ieActEd == NM_ITEM ) {
  596.         if ( NOT ieList->ml_First->em_Next ) {
  597.             if ( dummy = MakeDummy())
  598.                 AddTail(( struct List * )ieList, ( struct Node * )dummy );
  599.         }
  600.     }
  601.  
  602.     Saved = FALSE;
  603.  
  604.     if ( ieWnd )           CloseWindow( ieWnd );
  605.     if ( ieGList )         FreeGadgets( ieGList );
  606.  
  607.     ieWnd   = 0l;
  608.     ieGList = 0l;
  609.  
  610.     ClearMsgPort( meWnd->UserPort );
  611.  
  612.     return( TRUE );
  613. }
  614.